Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 22, 2025

This PR addresses issue #6054 by adding efficiency warnings to the apply_diff tool when only one SEARCH/REPLACE block is used, similar to how the read_file tool warns when only one file is read.

Changes Made

  1. Updated tool descriptions in diff strategies:

    • Added efficiency warning to multi-search-replace.ts getToolDescription
    • Added efficiency warning to multi-file-search-replace.ts getToolDescription
  2. Created dynamic warning functions:

    • Added getApplyDiffDescription in applyDiffTool.ts for legacy format
    • Added getApplyDiffDescription in multiApplyDiffTool.ts for multi-file format
    • These functions detect single SEARCH/REPLACE blocks and show appropriate warnings
  3. Updated assistant message presentation:

    • Modified presentAssistantMessage.ts to use the new description functions
    • Ensures warnings are shown to models during tool usage
  4. Added comprehensive tests:

    • Created getApplyDiffDescription.spec.ts with tests for both legacy and multi-file formats
    • Tests verify warnings appear for single blocks and not for multiple blocks

Benefits

  • Encourages models to batch multiple changes in a single apply_diff call
  • Reduces API usage and improves efficiency
  • Consistent with existing read_file tool behavior
  • Helps models learn better practices through inline guidance

Testing

All tests pass:

  • Unit tests for the new functionality ✅
  • Existing tool tests remain passing ✅
  • Linting and type checks pass ✅

Fixes #6054


Important

Adds efficiency warnings for single SEARCH/REPLACE blocks in apply_diff tool, encouraging batching of changes for improved efficiency.

  • Behavior:
    • Adds efficiency warnings for single SEARCH/REPLACE blocks in apply_diff tool, similar to read_file tool.
    • Updates getToolDescription in multi-search-replace.ts and multi-file-search-replace.ts to include warnings.
    • Introduces getApplyDiffDescription in applyDiffTool.ts and multiApplyDiffTool.ts to dynamically generate warnings.
  • Functionality:
    • Modifies presentAssistantMessage.ts to use new description functions for displaying warnings.
  • Testing:
    • Adds getApplyDiffDescription.spec.ts with tests for single and multiple SEARCH/REPLACE blocks.
    • Tests ensure warnings are shown for single blocks and not for multiple blocks.
  • Benefits:
    • Encourages batching multiple changes in a single apply_diff call.
    • Reduces API usage and improves efficiency.
    • Consistent with existing read_file tool behavior.

This description was created by Ellipsis for 4fcdea1. You can customize this summary. It will automatically update as commits are pushed.

…ly_diff

- Add warning message to tool descriptions when only one SEARCH/REPLACE block is used
- Update getToolDescription in multi-search-replace.ts and multi-file-search-replace.ts
- Create getApplyDiffDescription functions for dynamic warnings in tool usage
- Add comprehensive tests for the new warning functionality
- Similar to read_file tool efficiency warnings for better LLM context usage

Fixes #6054
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 22, 2025 07:53
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 22, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 22, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jul 23, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Draft / In Progress size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

apply_diff causes inefficient API usage when making single changes

3 participants